package com.aaa.service.sds.Impl;


import com.aaa.dao.sds.TSdsPlaneDao;
import com.aaa.entity.MyPage;
import com.aaa.entity.User;
import com.aaa.entity.sds.TSdsPlane;
import com.aaa.service.sds.TSdsPlaneService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * (TSdsPlane)表服务实现类
 *
 * @author makejava
 * @since 2022-10-27 16:55:09
 */
@Service
public class TSdsPlaneServiceImpl implements TSdsPlaneService {
   @Autowired
   private TSdsPlaneDao tSdsPlaneDao;

//   @Override
//   public PageInfo queryAllPlane(MyPage myPage, TSdsPlane tSdsPlane) {
//
//      System.out.println("========================================");
//      PageHelper.startPage(myPage.getPage(),myPage.getLimit());
//      List<TSdsPlane> tSdsPlanes = tSdsPlaneDao.queryAllPlane();
//      System.out.println("---------------------------------------");
//      System.out.println("tSdsPlanes = " + tSdsPlanes);
//      PageInfo pageInfo = new PageInfo(tSdsPlanes);
//      return pageInfo;
//   }

   @Override
   public boolean insertplan(TSdsPlane tSdsPlane, HttpSession session) {
      User user = (User) session.getAttribute("user");
      Integer id = user.getId();
      tSdsPlane.setUid(id);
      if (tSdsPlane.getId()==null){
         boolean insertplan = tSdsPlaneDao.insertplan(tSdsPlane);
      }else{
         boolean b = tSdsPlaneDao.updatePlan(tSdsPlane);
      }

      return true;
   }

   @Override
   public boolean updatePlan(TSdsPlane tSdsPlane) {
      boolean b = tSdsPlaneDao.updatePlan(tSdsPlane);
      return b;
   }

/*   @Override
   public TSdsPlane queryName(String planename) {
      TSdsPlane tSdsPlane = tSdsPlaneDao.queryName(planename);
      return tSdsPlane;
   }*/

   @Override
   public TSdsPlane queryByQyCode(TSdsPlane tSdsPlane) {
      TSdsPlane tSdsPlane1 = tSdsPlaneDao.selectOne(tSdsPlane);
      //selectOne()查询单个对象，返回实体类对象
      return tSdsPlane1;
   }

   /**
    * 模糊查询
    * @param myPage
    * @param tSdsPlane
    * @return
    */
   @Override
   public PageInfo querysdsAll(MyPage myPage, TSdsPlane tSdsPlane) {
      PageHelper.startPage(myPage.getPage(), myPage.getLimit());
      List<TSdsPlane> tSdsPlanes = tSdsPlaneDao.querysdsAll(tSdsPlane);
      System.out.println("=====================");
      System.out.println("tSdsPlanes = " + tSdsPlanes);
      return new PageInfo<>(tSdsPlanes);
   }


   /**
    * TSdsPlane(id=1, planename=null, begintime=Tue Oct 25 00:00:00 CST 2022, endtime=Fri Nov 25 00:00:00 CST 2022, code=f6706, uid=9, createtime=Tue Oct 25 18:23:05 CST 2022, updatetime=null, status=null,
    *          user=User(id=9, username=admin, password=779fa831dd6e8fae93bbd629f28bd304, salt=1aae2d0a-5281-477e-8939-e45cc2cafd96, sex=男, imgpath=https://yuyonglitst.oss-cn-beijing.aliyuncs.com/7990ac74-8fc3-42e5-8073-1f3aed75f9e6.jpg, rid=1, createtime=Tue Oct 25 18:23:05 CST 2022, updatetime=null, status=null))]
    */

}

